home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 1188 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.8 KB

  1. Path: engnews1.Eng.Sun.COM!taumet!clamage
  2. From: Alexander Krotoff <krotoff@boy.nmd.msu.ru>
  3. Newsgroups: comp.std.c++
  4. Subject: Re: auto_ptr problem?: delete or delete[]
  5. Date: 21 Apr 1996 15:33:47 GMT
  6. Organization: Research Computer Center, Moscow State University
  7. Approved: clamage@eng.sun.com (comp.std.c++)
  8. Message-ID: <199604211345.RAA02244@boy.nmd.msu.ru>
  9. Reply-To: krotoff@such.srcc.msu.su
  10. NNTP-Posting-Host: taumet.eng.sun.com
  11. X-Newsreader: TIN [version 1.2 PL2]
  12. Content-Length: 967
  13. Originator: clamage@taumet
  14.  
  15. In article <199604181455.QAA12877@bredex.bredex.de> you wrote:
  16. > In a tutorial a student asked a very good question i think:
  17. > How can auto_ptr imagine which delete to use.
  18. > Consider:
  19. >  int* p = new int;
  20. > and
  21. >  int* p = new int[10];
  22. > should result in different delete operations.
  23. > But if I let auto_ptr do the job, how does it know
  24. > which one to use?
  25.  
  26. Reading WP I was confused too. Really, we need auto_ptr for array
  27. of objects more often, than auto_ptr for single object. In the last
  28. case we are able to use simple auto object instead of dynamic
  29. allocation and closely link allocated object with the automatic
  30. object (of auto_ptr type).
  31.  
  32. Yes, I know there are several applications of auto_ptr which cannot
  33. be solved just by auto objects...
  34.  
  35. Probably somebody from ANSI committee library WG may clean the situation.
  36.  
  37. --
  38. Alexander N. Krotoff        krotoff@such.srcc.msu.su
  39. Research Computer Center    tel: +7(095)939-2638
  40. Moscow State University        fax: +7(095)939-4430
  41.  
  42.  
  43. [ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
  44. [ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
  45. [ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
  46. [ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
  47. [ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]
  48.